package com.xbongbong.pro.enums.permission.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/4/23 19:35
 * @since v1.0
 */
@Getter
public enum UpdateProPermissionAliasEnum {

    /**
     * tb_pro_promission对应的alias字段
     */
    CUSTOMER_UPDATE(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), "customerUpdate", ProPermissionAliasEnum.CUSTOMER_UPDATE.getI18nMemo()),

    WORK_ORDER_UPDATE(XbbRefTypeEnum.WORK_ORDER.getCode(), "workOrderUpdate", ProPermissionAliasEnum.WORK_ORDER_UPDATE.getI18nMemo()),

    OPPORTUNITY_UPDATE(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), "opportunityUpdate", ProPermissionAliasEnum.OPPORTUNITY_UPDATE.getI18nMemo()),

    CONTRACT_UPDATE(XbbRefTypeEnum.CONTRACT.getCode(), "contractUpdate", ProPermissionAliasEnum.CONTRACT_UPDATE.getI18nMemo()),

    REFUND_UPDATE(XbbRefTypeEnum.REFUND.getCode(), "refundEdit", ProPermissionAliasEnum.REFUND_EDIT.getI18nMemo()),

    CONTACT_UPDATE(XbbRefTypeEnum.CONTACT.getCode(), "contactUpdate", ProPermissionAliasEnum.CONTACT_UPDATE.getI18nMemo()),

    WORK_REPORT_UPDATE(XbbRefTypeEnum.WORK_REPORT.getCode(), "workReportUpdate", ProPermissionAliasEnum.WORK_REPORT_UPDATE.getI18nMemo()),

    PAYMENT_UPDATE(XbbRefTypeEnum.PAYMENT.getCode(), "paymentUpdate", ProPermissionAliasEnum.PAYMENT_UPDATE.getI18nMemo()),

    PURCHASE_UPDATE(XbbRefTypeEnum.PURCHASE.getCode(), "purchaseUpdate", ProPermissionAliasEnum.PURCHASE_UPDATE.getI18nMemo()),

    SUPPLIER_UPDATE(XbbRefTypeEnum.SUPPLIER.getCode(), "supplierUpdate", ProPermissionAliasEnum.SUPPLIER_UPDATE.getI18nMemo()),

    INSTOCK_UPDATE(XbbRefTypeEnum.INSTOCK.getCode(), "instockUpdate", ProPermissionAliasEnum.INSTOCK_UPDATE.getI18nMemo()),

    OTHER_INSTOCK_UPDATE(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), "instockUpdate", ProPermissionAliasEnum.INSTOCK_UPDATE.getI18nMemo()),

    PURCHASE_INSTOCK_UPDATE(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), ProPermissionAliasEnum.PURCHASE_INSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.PURCHASE_INSTOCK_UPDATE.getI18nMemo()),

    REFUND_INSTOCK_UPDATE(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), ProPermissionAliasEnum.REFUND_INSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.REFUND_INSTOCK_UPDATE.getI18nMemo()),

    PRODUCTION_INSTOCK_UPDATE(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_INSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.PRODUCTION_INSTOCK_UPDATE.getI18nMemo()),

    RETURNED_MATERIEL_INSTOCK_UPDATE(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_UPDATE.getI18nMemo()),

    CONTRACT_OUTSTOCK_UPDATE(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK_UPDATE.getI18nMemo()),

    PRODUCTION_MATERIEL_OUTSTOCK_UPDATE(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_UPDATE.getI18nMemo()),

    WORK_ORDER_OUTSTOCK_UPDATE(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_UPDATE.getI18nMemo()),

    RETURNED_PURCHASE_OUTSTOCK_UPDATE(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_UPDATE.getAlias(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_UPDATE.getI18nMemo()),

    OUTSTOCK_UPDATE(XbbRefTypeEnum.OUTSTOCK.getCode(), "outstockUpdate", ProPermissionAliasEnum.OUTSTOCK_UPDATE.getI18nMemo()),

    OTHER_OUTSTOCK_UPDATE(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), "outstockUpdate", ProPermissionAliasEnum.OUTSTOCK_UPDATE.getI18nMemo()),

    INVENTORY_UPDATE(XbbRefTypeEnum.INVENTORY.getCode(), "inventoryUpdate", ProPermissionAliasEnum.INVENTORY_UPDATE.getI18nMemo()),

    TRANSFER_UPDATE(XbbRefTypeEnum.TRANSFER.getCode(), "transferUpdate", ProPermissionAliasEnum.TRANSFER_UPDATE.getI18nMemo()),

    WAREHOUSE_UPDATE(XbbRefTypeEnum.WAREHOUSE.getCode(), "warehouseUpdate", ProPermissionAliasEnum.WAREHOUSE_UPDATE.getI18nMemo()),

    RETURN_PURCHASE_UPDATE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), "returnPurchaseUpdate", ProPermissionAliasEnum.RETURN_PURCHASE_UPDATE.getI18nMemo()),

    PAY_PLAN_UPDATE(XbbRefTypeEnum.PAY_PLAN.getCode(), "payPlanUpdate", ProPermissionAliasEnum.PAY_PLAN_UPDATE.getI18nMemo()),

    ASSEMBLE_UPDATE(XbbRefTypeEnum.ASSEMBLE.getCode(), "assembleUpdate", ProPermissionAliasEnum.ASSEMBLE_UPDATE.getI18nMemo()),

    INVOICE_UPDATE(XbbRefTypeEnum.INVOICE.getCode(), "invoiceUpdate", ProPermissionAliasEnum.INVOICE_UPDATE.getI18nMemo()),

    CUSTOMER_COMMUNICATE_UPDATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), "customerCommunicateUpdate", ProPermissionAliasEnum.CUSTOMER_COMMUNICATE_UPDATE.getI18nMemo()),

    BOM_BILL_UPDATE(XbbRefTypeEnum.BOM_BILL.getCode(), "bomBillUpdate", ProPermissionAliasEnum.BOM_BILL_UPDATE.getI18nMemo()),

    PRODUCTION_ORDER_UPDATE(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), "productionOrderUpdate", ProPermissionAliasEnum.PRODUCTION_ORDER_UPDATE.getI18nMemo()),

    COMMUNICATE_PLAN_UPDATE(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), "communicatePlanUpdate", ProPermissionAliasEnum.COMMUNICATE_PLAN_UPDATE.getI18nMemo()),

    PRODUCT_UPDATE(XbbRefTypeEnum.PRODUCT.getCode(), "productUpdate", ProPermissionAliasEnum.PRODUCT_UPDATE.getI18nMemo()),

    SUPPLIER_CONTACT_UPDATE(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), "supplierContactUpdate", ProPermissionAliasEnum.SUPPLIER_CONTACT_UPDATE.getI18nMemo()),

    SUPPLIER_COMMUNICATE_UPDATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), "supplierCommunicateUpdate", ProPermissionAliasEnum.SUPPLIER_COMMUNICATE_UPDATE.getI18nMemo()),

    QUOTATION_UPDATE(XbbRefTypeEnum.QUOTATION.getCode(), ProPermissionAliasEnum.QUOTATION_UPDATE.getAlias(), ProPermissionAliasEnum.QUOTATION_UPDATE.getI18nMemo()),

    PAYMENT_SHEET_UPDATE(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), ProPermissionAliasEnum.PAYMENT_SHEET_UPDATE.getAlias(), ProPermissionAliasEnum.PAYMENT_SHEET_UPDATE.getI18nMemo()),

    PAY_SHEET_UPDATE(XbbRefTypeEnum.PAY_SHEET.getCode(), ProPermissionAliasEnum.PAY_SHEET_UPDATE.getAlias(), ProPermissionAliasEnum.PAY_SHEET_UPDATE.getI18nMemo()),

    //回款计划编辑
    PAYMENT_TASK_UPDATE(XbbRefTypeEnum.PAYMENT_TASK.getCode(), ProPermissionAliasEnum.PAYMENT_TASK_UPDATE.getAlias(), ProPermissionAliasEnum.PAYMENT_TASK_UPDATE.getI18nMemo()),
    //编辑
    MARKET_ACTIVITY_UPDATE(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), ProPermissionAliasEnum.MARKET_ACTIVITY_UPDATE.getAlias(), ProPermissionAliasEnum.MARKET_ACTIVITY_UPDATE.getI18nMemo()),
    CLUE_UPDATE(XbbRefTypeEnum.CLUE.getCode(), ProPermissionAliasEnum.CLUE_UPDATE.getAlias(), ProPermissionAliasEnum.CLUE_UPDATE.getI18nMemo()),

    /**
     * 经销商
     */
    DISTRIBUTOR_MANAGEMENT(XbbRefTypeEnum.DISTRIBUTOR_MANAGEMENT.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_EDIT.getAlias(), ProPermissionAliasEnum.DISTRIBUTOR_EDIT.getI18nMemo()),
    DISTRIBUTOR_CONTACT(XbbRefTypeEnum.DISTRIBUTOR_CONTACT.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_CONTACT_EDIT.getAlias(), ProPermissionAliasEnum.DISTRIBUTOR_CONTACT_EDIT.getI18nMemo()),
    DISTRIBUTOR_COMMUNICATE(XbbRefTypeEnum.DISTRIBUTOR_COMMUNICATE.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_COMMUNICATE_EDIT.getAlias(), ProPermissionAliasEnum.DISTRIBUTOR_COMMUNICATE_EDIT.getI18nMemo()),
    DISTRIBUTOR_ACCOUNT(XbbRefTypeEnum.DISTRIBUTOR_ACCOUNT.getCode(), ProPermissionAliasEnum.DISTRIBUTOR_ACCOUNT_EDIT.getAlias(), ProPermissionAliasEnum.DISTRIBUTOR_ACCOUNT_EDIT.getI18nMemo()),
    ORDER(XbbRefTypeEnum.ORDER.getCode(), ProPermissionAliasEnum.ORDER_EDIT.getAlias(), ProPermissionAliasEnum.ORDER_EDIT.getI18nMemo()),
    RETURN(XbbRefTypeEnum.RETURN.getCode(), ProPermissionAliasEnum.RETURN_EDIT.getAlias(), ProPermissionAliasEnum.RETURN_EDIT.getI18nMemo()),

    OTHER_INCOME_UPDATE(XbbRefTypeEnum.OTHER_INCOME.getCode(), ProPermissionAliasEnum.OTHER_INCOME_UPDATE.getAlias(), ProPermissionAliasEnum.OTHER_INCOME_UPDATE.getI18nMemo()),
    OTHER_EXPENSE_UPDATE(XbbRefTypeEnum.OTHER_EXPENSE.getCode(), ProPermissionAliasEnum.OTHER_EXPENSE_UPDATE.getAlias(), ProPermissionAliasEnum.OTHER_EXPENSE_UPDATE.getI18nMemo()),
    FUND_TRANSFER_UPDATE(XbbRefTypeEnum.FUND_TRANSFER.getCode(), ProPermissionAliasEnum.FUND_TRANSFER_UPDATE.getAlias(), ProPermissionAliasEnum.FUND_TRANSFER_UPDATE.getI18nMemo()),
    // 服务项目
    SERVICE_PROJECT_UPDATE(XbbRefTypeEnum.SERVICE_PROJECT.getCode(), ProPermissionAliasEnum.SERVICE_PROJECT_UPDATE.getAlias(), ProPermissionAliasEnum.SERVICE_PROJECT_UPDATE.getI18nMemo()),
    // 工单
    WORK_ORDER_V2_UPDATE(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), ProPermissionAliasEnum.WORK_ORDER_V2_EDIT.getAlias(), ProPermissionAliasEnum.WORK_ORDER_V2_EDIT.getI18nMemo()),
    // 回执单
    RECEIPT_ORDER_UPDATE(XbbRefTypeEnum.RECEIPT_ORDER.getCode(), ProPermissionAliasEnum.RECEIPT_ORDER_EDIT.getAlias(), ProPermissionAliasEnum.RECEIPT_ORDER_EDIT.getI18nMemo()),


    /**
     * 竞争对手
     */
    COMPETITOR_UPDATE(XbbRefTypeEnum.COMPETITOR.getCode(),ProPermissionAliasEnum.COMPETITOR_EDIT.getAlias(),ProPermissionAliasEnum.COMPETITOR_EDIT.getI18nMemo())
    ;

    private Integer code;

    private String alias;

    private String memo;

    UpdateProPermissionAliasEnum(Integer code, String alias, String memo) {
        this.code = code;
        this.alias = alias;
        this.memo = memo;
    }

    public static UpdateProPermissionAliasEnum getByCode(Integer businessType) {
        for (UpdateProPermissionAliasEnum item: values()) {
            if (Objects.equals(item.getCode(), businessType)) {
                return item;
            }
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
